<!DOCTYPE html>
<html>
  <head>
    <title><%= title %></title>
    <link rel='stylesheet' href='/stylesheets/style.css' />
  </head>
  <body>
    <h1><%= title %></h1>
    <p>Welcome to <%= title %></p>
  </body>
</html>
<%- include ../include/header.ejs%>
<div class="container-fluid">
    <div class="row">
        <div class="col-sm-2">
            <%- include ../include/left.ejs%>
        </div>
        <div class="col-sm-10">
            <ol class="breadcrumb">
                <li class="active">商品管理</li>
                <li class="active">商品列表</li>
            </ol>
            <div class="panel panel-default">
                <div class="panel-heading">搜索</div>
                <div class="panel-body">
                    <form role="form" class="form-inline" action='/admin/search' method="get">
                        <div class="form-group">
                            <label for="name">名称</label>
                            <input type="text" class="form-control" id="name" placeholder="请输入名称" name='key1'>
                        </div>
                        <div class="form-group">
                            <button type="submit" class="btn btn-default">开始搜索</button>
                          </div>
                        </form>
                        </div>
                        </div>
                        <!--列表展示-->
                        <div class="table-responsive">
                            <table class="table table-striped">
                                <thead>
                                    <tr>
                                        <th>编号</th>
                                        <th>图标</th>
                                        <th>名称</th>
                                        <th>价格</th>
                                        <th>添加时间</th>
                                        <th class="text-center">操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <% for(var i=0;i<list.length;i++){ %> // 循环变量从数组索引0开始 
                                    <tr> // 每个商品为表格中的一行 
                                        <td><%=(i+1)%></td> // 从编号1开始，数组索引加1 
                                        <!--建立虚拟目录去匹配图片地址-->
                                        <td><img src="/<%= list[i].image%>" width="150px" height="100px"></td>
                                        <td><%=list[i].name %></td>
                                        <td><%=list[i].price%></td>
                                        <td><%=list[i].add_time.toLocaleDateString() %></td>
                                        <td class="text-center">
                                            <a href="/admin/edit?id=<%= list[i].id%>" class="btn btn-success">修改</a>
                                            <a href="/admin/delete?id=<%= list[i].id%>" onclick="return confirm('确定要删除吗？');" class="btn btn-danger">删除</a>
                                        </td>
                                    </tr>
                                    <% } %>
                                </tbody>
                            </table>
                            <center>
                                <section class="page">
                                    <% if(yemashu>0){ %>
                                    共<%= yemashu %>页，页码: 
                                    <% for (var i=1;i<=yemashu;i++){ 
                                        if (i==page) {  %>
                                            <span class="pageactive"><a href="?page=<%= i %>"><%= i %></a></span>&nbsp;&nbsp;
                                        <% } else { %>
                                            <span><a href="?page=<%= i %>"><%= i %></a></span>&nbsp;&nbsp;
                                        <% } 
                                    } %>
                                    <% } %>
                                </section>
                            </center>
                        </div>
                      </div>
                    </div>
                  </body>
                </htmi>
                        